package com.example.demo;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.domain.AuditorAware;
import org.springframework.data.jpa.repository.config.EnableJpaAuditing;
//import org.springframework.security.core.Authentication;
//import org.springframework.security.core.context.SecurityContextHolder;

import java.util.Optional;
import java.util.UUID;

@Configuration
@EnableJpaAuditing(modifyOnCreate = false)
public class DemoConfig {

    @Bean
    public AuditorAware<UUID> auditorAwareProvider() {
        return new AuditorAware<UUID>() {
            @Override
            public Optional<UUID> getCurrentAuditor() {
//                Authentication auth = SecurityContextHolder.getContext().getAuthentication();
                return Optional.of(UUID.randomUUID());
            }
        };
    }
}
